package cn.krui.helper.bean;

import java.io.Serializable;

import cn.krui.helper.tools.CodeUtils;

/**
 * @author zc
 * @param 泛型
 */
public class AppResult<T> implements Serializable {
    private int code = CodeUtils.ERROR;;
    private String msg = "";
    private T dataSingle;
    private DataArray<T> dataArray;
    private String ext;

    public AppResult() {

    }

    public AppResult(int code) {
        this.code = code;
    }

    public AppResult(String msg) {
        this.msg = msg;
    }

    public AppResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public void ok(String msg) {
        this.code = CodeUtils.SUCCEED;
        this.msg = msg;
    }

    public void ok() {
        this.code = CodeUtils.SUCCEED;
        this.msg = "";
    }

    public void no(String msg) {
        this.code = CodeUtils.ERROR;
        this.msg = msg;
    }

    public void no(int errorCode, String msg) {
        this.code = errorCode;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getDataSingle() {
        return dataSingle;
    }

    public void setDataSingle(T dataSingle) {
        this.dataSingle = dataSingle;
        this.ok();
    }

    public DataArray<T> getDataArray() {
        return dataArray;
    }

    public void setDataArray(DataArray<T> dataArray) {
        this.dataArray = dataArray;
        this.ok();
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }

}